Skip to content

docs(drive): clarify download command is for Workspace native formats, not binary files#836

Open
nuthalapativarun wants to merge 1 commit into
googleworkspace:mainfrom
nuthalapativarun:fix/727-drive-download-docs
Open

docs(drive): clarify download command is for Workspace native formats, not binary files#836
nuthalapativarun wants to merge 1 commit into
googleworkspace:mainfrom
nuthalapativarun:fix/727-drive-download-docs

Conversation

@nuthalapativarun
Copy link
Copy Markdown

Description

The gws drive files export command is designed for exporting Google Workspace native formats (Docs → PDF, Sheets → CSV, etc.). Using it on binary files (PDFs, images, Office documents already stored as binary blobs) returns a 500 backendError, which was confusing users.

Added a clarifying NOTE section to the export command's --help output that:

  • Explains it only works on Google Workspace native MIME types
  • Names the specific error users see on binary files
  • Shows the correct alternative (gws drive files get --params '{"alt": "media", ...}') for binary file downloads
  • Includes concrete examples for both export and binary-download workflows

The note is injected in build_resource_command in commands.rs when service == "drive", resource == "files", and method == "export", keeping all service-specific help text co-located with command construction rather than spread across helper files.

A new unit test test_drive_files_export_after_help verifies the note appears in the generated command's after_help text.

Closes #727

Checklist:

  • My code follows the AGENTS.md guidelines (no generated google-* crates).
  • I have run cargo fmt --all to format the code perfectly.
  • I have run cargo clippy -- -D warnings and resolved all warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have provided a Changeset file (e.g. via pnpx changeset) to document my changes.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request improves the user experience for the gws drive files export command by clarifying its limitations regarding binary files. By injecting a descriptive note into the command's help output, users are now correctly directed to use the get command for binary downloads, preventing confusion caused by unexpected 500 backend errors.

Highlights

  • Documentation Update: Added a clarifying note to the gws drive files export command help text to explain that it is intended for Google Workspace native formats and to provide guidance on handling binary files.
  • Code Refactoring: Updated build_resource_command to accept the service_name parameter, enabling context-aware help text injection.
  • Testing: Added a new unit test test_drive_files_export_after_help to verify that the help text is correctly injected into the CLI command.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Generative AI Prohibited Use Policy, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 2, 2026

🦋 Changeset detected

Latest commit: cbf175d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@googleworkspace/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@googleworkspace-bot googleworkspace-bot added the area: core Core CLI parsing, commands, error handling, utilities label Jun 2, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds clarifying help text to the gws drive files export command to help users distinguish it from the get command when downloading binary files, and includes a corresponding unit test and changeset. The reviewer feedback suggests simplifying the implementation by leveraging the existing method.id field (e.g., 'drive.files.export') to identify the target command, which avoids modifying the signature of build_resource_command and passing the service_name parameter recursively.

for name in resource_names {
let resource = &doc.resources[name];
if let Some(cmd) = build_resource_command(name, resource) {
if let Some(cmd) = build_resource_command(&doc.name, name, resource) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Revert passing &doc.name to build_resource_command since we can use method.id directly to identify the target command.

Suggested change
if let Some(cmd) = build_resource_command(&doc.name, name, resource) {
if let Some(cmd) = build_resource_command(name, resource) {
References
  1. Avoid introducing changes that are outside the primary goal of a pull request to prevent scope creep.

Comment on lines +75 to +78
///
/// `service_name` is the top-level API service (e.g. `"drive"`) used to inject
/// service-specific help text into selected commands.
fn build_resource_command(service_name: &str, name: &str, resource: &RestResource) -> Option<Command> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Revert the signature of build_resource_command to avoid passing the unused service_name parameter.

fn build_resource_command(name: &str, resource: &RestResource) -> Option<Command> {
References
  1. Avoid introducing changes that are outside the primary goal of a pull request to prevent scope creep.


// Inject service-specific after_help notes for commands that are
// commonly confused with similar-sounding operations.
if service_name == "drive" && name == "files" && method_name == "export" {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Instead of passing service_name through the recursive call stack and performing ad-hoc string matching on service_name, name, and method_name, you can leverage the unique method identifier method.id (e.g., "drive.files.export") which is already provided by the Discovery Document schema.

Using method.id simplifies the condition and allows you to completely revert the signature changes to build_resource_command (removing the service_name parameter and its propagation in build_cli and the recursive call).

Suggested change
if service_name == "drive" && name == "files" && method_name == "export" {
if method.id.as_deref() == Some("drive.files.export") {
References
  1. Avoid introducing changes that are outside the primary goal of a pull request to prevent scope creep.

for sub_name in sub_names {
let sub_resource = &resource.resources[sub_name];
if let Some(sub_cmd) = build_resource_command(sub_name, sub_resource) {
if let Some(sub_cmd) = build_resource_command(service_name, sub_name, sub_resource) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Revert passing service_name recursively.

Suggested change
if let Some(sub_cmd) = build_resource_command(service_name, sub_name, sub_resource) {
if let Some(sub_cmd) = build_resource_command(sub_name, sub_resource) {
References
  1. Avoid introducing changes that are outside the primary goal of a pull request to prevent scope creep.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core Core CLI parsing, commands, error handling, utilities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

drive files download vs drive files get --params alt=media: guide which to use; download returns 500 backendError on ordinary files

2 participants